# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------
# Copyright © 2010, RedJack, LLC.
# All rights reserved.
#
# Please see the LICENSE.txt file in this distribution for license
# details.
# ----------------------------------------------------------------------


def set_options(opt):
    opt.tool_options("compiler_cc")
    opt.tool_options("misc")


def configure(conf):
    conf.check_tool("compiler_cc")
    conf.check_tool("misc")

    conf.check_cfg(atleast_pkgconfig_version="0.15.0")
    conf.check_cfg(
        package="check",
        uselib_store="CHECK",
        args="--cflags --libs",
        mandatory=True
    )


def build(bld):
    def make_test(test_name):
        test = bld(
            features = "cc cprogram",
            source = "%s.c" % test_name,
            target = test_name,
            uselib = "GLIB CHECK",
            uselib_local = "ipset",
            install_path = None,
            includes = [
                "../include",
            ],
            rpath = [
                "$ORIGIN/../src",
            ],
        )

        test.unit_test = True

    make_test("test-assignment")
    make_test("test-bdd")
    make_test("test-ip")
    make_test("test-ipmap")
    make_test("test-ipset")
    make_test("test-iterator")
